package com.rd.student.jike.class1.sunhao.day03;

public class Test1 {
    public static void main(String[] args) {
       xing.x3(4);
    }
}

class xing{
    public static void x(int sum){
        for (int i=1;i<=sum;i++){
            for(int j=sum;j>i;j--){
                System.out.print(" ");
            }
            int p=(i-1)*2+1;
            for (int k=0;k<p;k++){
                System.out.print("*");
            }
            System.out.println();
        }
    }
    public static void x1(int sum){
        for (int i=1;i<=sum;i++){
            for (int j=sum;j>i;j--){
                System.out.print(" ");
            }
            for (int k=i;k>1;k--){
                System.out.print(k);
            }
            for (int p=1;p<=i;p++){
                System.out.print(p);
            }
            System.out.println();
        }
    }
    public static void x3(float sum){
        int[][] a= new int[(int)sum][(int)sum];
        float s=sum*sum;
        int x=0;
        int y=0;
        for (int i=1;i<=s ;i++){
            for (int j=0;j<=Math.floor(sum/2);j++) {
                if (x==j&&y!=sum){
                    a[x][y]=i;
                    y++;
                }
                if (x!=sum&&y==sum){
                    a[x][y]=i;
                    x++;
                }
                if (x==sum&&y!=j){
                    a[x][y]=i;
                    y--;
                }
                if (x!=j&&y==j){
                    a[x][y]=i;
                    x--;
                }

            }
        }
        System.out.println(a);
    }
}